package top.kaoshanji.ch04;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 代码清单 ch04-02：InetAddress示例(4.1.4节)
 * author kaoshanji
 * ^_^
 * create time 2024/12/7 18:35
 */
public class InetAddressTest {

    private static final Logger logger = LogManager.getLogger(InetAddressTest.class);

    public static void main(String[] args) throws UnknownHostException {
        logger.info("...代码清单 ch04-02：InetAddress示例(4.1.4节)...");

        String horstHostAddress = "www.horstmann.com";
        InetAddress[] addresses = InetAddress.getAllByName(horstHostAddress);
        for (InetAddress address: addresses) {
            System.out.println(address);
        }

        InetAddress localHostAddress = InetAddress.getLocalHost();
        System.out.println(localHostAddress);

    }

}
